


let Maybe = function (x) {
    this._value = x;
};

Maybe.of = function (x) {
    return new Maybe(x)
};

// prototype
Maybe.prototype.map = function (f) {
    return this.isNothing()?new Maybe(null):new Maybe(f(this._value))
};


Maybe.prototype.isNothing = function () {
    return this._value === null ||  this._value === undefined
};

module.exports = Maybe;
